package com.xhc.demo;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import com.xhc.demo.utils.WxPayCertificateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.atomic.AtomicLong;

public class GlobalConfig {
    private static final Logger logger = LoggerFactory.getLogger(GlobalConfig.class);
    
    public static final String APP_ID = "wx5b0dcacbbe1636ff";
    public static final String APP_SECRET = "f54f68ae0967a1c2056ad038332a2730";
    public static final String PAY_MCHID = "1709943706";
    public static final String PAY_API_v3 = "bT7yQmX9Rk3vZ6LpNwA2sU8gFd1jHc1d";
    public static final String PAY_API_v2 = "z5F8qLcR2mVnWxT9KpYd7H3sG4Jk6N5s";
    public static final String QINIU_AK = "x22AECheoI6QFQfz22inM0CNfiOYOBJsCZwMKJoS";
    public static final String QINIU_SK = "sStT6UEOvblfPRzzG6EsPCOy-D_3Jkgyq_9L2HTH";
    public static final String QINIU_DOMAIN = "https://img.mrxxhc.cn/";

    // 微信支付证书配置
    public static final String PAY_SERIAL_NO = WxPayCertificateUtil.getCertificateSerialNumber(
        "/home/photo/pay/apiclient_cert.pem",  // 使用pem格式的证书文件
        PAY_MCHID  // 商户号
    );

    public static AtomicLong maxUserId = new AtomicLong(0);

    public static void setMaxUserId(Long maxUserId) {
        GlobalConfig.maxUserId.set(maxUserId);
    }

    public static Long getMaxUserId() {
        return maxUserId.get();
    }

    static {
        // 打印证书配置信息
        logger.info("[PAY] Certificate serial number: {}", PAY_SERIAL_NO);
        logger.info("[PAY] APP_ID: {}", APP_ID);
        logger.info("[PAY] APP_SECRET: {}", APP_SECRET);
        logger.info("[PAY] PAY_MCHID: {}", PAY_MCHID);
        logger.info("[PAY] PAY_API_v3: {}", PAY_API_v3);
        logger.info("[PAY] PAY_API_v2: {}", PAY_API_v2);
        logger.info("[PAY] QINIU_AK: {}", QINIU_AK);
        logger.info("[PAY] QINIU_SK: {}", QINIU_SK);
        logger.info("[PAY] QINIU_DOMAIN: {}", QINIU_DOMAIN);
    }
}
